package com.itheima.mapper;


import com.itheima.pojo.EmpQueryParam;
import com.itheima.pojo.StuQueryParam;
import com.itheima.pojo.Student;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {


    //根据id查询班级人数
    @Select("select count(*) from student where clazz_id = #{id}")
    public Integer countByClazzId(Integer id);

    //动态查询
    public ArrayList<Student> list(StuQueryParam stuQueryParam);

    @Delete("delete from student where id = #{id}")
    public void delete(Integer id);

    @Insert("insert into student (name, no, gender, phone, degree, clazz_id, id_card, is_college, address,  graduation_date, create_time, update_time)" +
            " value (#{name}, #{no}, #{gender}, #{phone}, #{degree}, #{clazzId}, #{idCard}, #{isCollege}, #{address}, #{graduationDate}, #{createTime}, #{updateTime})")
    public void add(Student student);

    @Select("select * from student where id = #{id}")
    public Student getInfo(Integer id);

    /**
     * 更新学员信息
     * @param student
     */
    public void update(Student student);

    @Update("update student set violation_count = violation_count + 1, violation_score = violation_count + #{score}, update_time = now() where id = #{id}")
    public void violationHandle(Integer id, Integer score);

    /**
     * 统计学员的学历分布情况
     */

    public List<Map<String, Object>> countStudentDegreeData();

    public List<Map<String, Object>> getStudentCount();


}
